﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace BankRemoteSystem.DAL
{
    class TransactionAO 
    {
        public SqlDataAdapter sqldtStudent;
        public DataSet dtStudent;
        List<SqlParameter> sqlpa;
        SqlParameter temp;
        
        Connection con;
        public TransactionAO()
        {
            con = new Connection();
        }
        public DataSet getAll()
        {
            sqldtStudent = new SqlDataAdapter();
            SqlCommandBuilder sqlcombSouthAngle = new SqlCommandBuilder(sqldtStudent);
            dtStudent = new DataSet();
            Connection cdb = new Connection();
            string sql = "select * from [Transaction]";
            sqldtStudent.SelectCommand = new SqlCommand(sql, cdb.getConnection());
            sqldtStudent.Fill(dtStudent, "Transaction");
            return dtStudent;

        }
        public bool insertTrans(Entities.Transaction trans)
        {
            sqlpa = new List<SqlParameter>();
            temp = new SqlParameter();
            string strSql = "spInsertTransaction";
            temp.ParameterName = "@accountID";
            temp.SqlDbType = SqlDbType.NVarChar;
            temp.Value = trans.AccountID;
            sqlpa.Add(temp);
            temp = new SqlParameter();
            temp.ParameterName = "@date";
            temp.SqlDbType = SqlDbType.DateTime;
            temp.Value = trans.Date;
            sqlpa.Add(temp);
            temp = new SqlParameter();
            temp.ParameterName = "@action";
            temp.SqlDbType = SqlDbType.NVarChar;
            temp.Value = trans.Action;
            sqlpa.Add(temp);
            return con.MyExecuteNonQuery(strSql, CommandType.StoredProcedure, sqlpa);
        }
    }
}
